package com.songlanyun.modules.goods.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.modules.goods.dao.GoodsContentDao;
import com.songlanyun.modules.goods.entity.GoodsContent;
import com.songlanyun.modules.goods.service.GoodsContentService;
import org.springframework.stereotype.Service;


@Service("goodsContentService")
public class GoodsContentServiceImpl extends ServiceImpl<GoodsContentDao, GoodsContent> implements GoodsContentService {


    @Override
    public void setGoodsContent(Long goodsId, String content) {
        GoodsContent goodsContent = this.getByGoodsId(goodsId);
        if(goodsContent!=null)
        {
            goodsContent.setMobileDetail(content);
            this.baseMapper.updateById(goodsContent);
        }
        else
        {
            goodsContent = new GoodsContent();
            goodsContent.setMobileDetail(content);
            goodsContent.setGoodsId(goodsId);
            this.baseMapper.insert(goodsContent);
        }
    }

    @Override
    public GoodsContent getByGoodsId(Long goodsId) {
        GoodsContent content = this.baseMapper.getByGoodsId(goodsId);
        return content;
    }
}